<?php

import('Psg.Core');

function getProfilePicture_action($id, $size = 64) {
    header('Content-Type: image/jpeg');
    $imgDir = DSF_DATADIR . DS . 'images' . DS;
    if (!file_exists($imgDir . 'profile' . DS . $id . '.jpg')) {
        $path = $imgDir . 'noprofile.jpg';
    } else {
        $path = $imgDir . 'profile' . DS . $id . '.jpg';
    }
    $image = imagecreatefromjpeg($path);
    $newimage = imagecreatetruecolor($size, $size);
    list($w, $h) = getimagesize($path);
    imagecopyresampled($newimage, $image, 0, 0, 0, 0, $size, $size, $w, $h);
    imagejpeg($newimage);
    imagedestroy($image);
    imagedestroy($newimage);
}